<!--
 * @Author       : xh
 * @Date         : 2022-04-27 09:50:05
 * @LastEditors  : xh
 * @FileName     :
-->
<template>
  <div id="app">
    <router-view v-if="isRouterAlive" />
  </div>
</template>

<script>
import actions from './action'

export default {
  provide() {
    return {
      reload: this.reload
    }
  },
  data() {
    return {
      isRouterAlive: true
    }
  },
  computed() {},
  mounted() {
    actions.onGlobalStateChange((arg) => {
      // debugger
      if (this.$store.getters.sidebar.opened != arg.opened) {
        this.$store.dispatch('app/toggleSideBar')
      }
    })
  },
  methods: {
    reload() {
      this.isRouterAlive = false
      this.$nextTick(() => {
        this.isRouterAlive = true
      })
    }
  }
}
</script>
